<template>
  <div style="text-align: center;">
    <span class="s1">广沣共享典当管理平台</span>
    <el-row>
      <el-col :span="6" :offset="8">
        <el-form label-width="80px">
          <el-form-item label="用户名">
            <el-input v-model="username" placeholder="请输入用户名"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input show-password v-model="password" placeholder="请输入密码"></el-input>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="loginUser">登录</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>



</template>

<script>
  export default {
    name: 'login',
    data() {
      return {
        username: "",
        password: ""
      }
    },
    methods: {
      loginUser() {
        let login1 = new URLSearchParams();
        login1.append("username", this.username);
        login1.append("password", this.password)

        this.$http.post("login", login1).then(resp => {
          alert(resp.data.message)
          if (resp.data.flag) {
            localStorage.setItem("loginAccount", JSON.stringify(resp.data.data))
            this.$router.push("/manager")
          }
        })
      },

    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .s1 {
    color: #2C3E50;
  }
</style>
